const db = require('../db/index')
exports.getGoods = (req, res) => {
    const query = req.query.query
    const pagenum = req.query.pagenum
    const pagesize = req.query.pagesize
    var sql = "select * from sp_goods"
    db.query(sql, (err, result) => {
        // console.log(result.length);
        var total = result.length
        var page = pagenum * pagesize
        if (page > total) return res.ResData('错误')
        let arr = []
        for (idx in result) {
            idx = idx * 1.0 + page - pagesize
            if (idx == page || idx == total) return res.ResData('获取成功', 200, arr)
            arr.push({
                "goods_id": result[idx].goods_id,
                "goods_name": result[idx].goods_name,
                "goods_price": result[idx].goods_price,
                "goods_number": result[idx].goods_number,
                "goods_weight": result[idx].goods_weight,
                "goods_state": result[idx].goods_state,
                "add_time": result[idx].add_time,
                "upd_time": result[idx].upd_time,
                "hot_mumber": result[idx].hot_mumber,
                "is_promote": result[idx].is_promote
            })
        }
    })


}